namespace soccer.helper {

    import b2Vec2 = Box2D.Common.Math.b2Vec2;
    import b2BodyDef = Box2D.Dynamics.b2BodyDef;
    import b2Body = Box2D.Dynamics.b2Body;
    import b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape;
    import b2FixtureDef = Box2D.Dynamics.b2FixtureDef;
    import b2CircleShape = Box2D.Collision.Shapes.b2CircleShape;

    export enum PhyObjectType {
        TapA = 1 << 0,
        TapB = 1 << 1,
        DoorA = 1 << 2,
        DoorB = 1 << 3,
        Ball = 1 << 4,
    }

    export class PhyObject {
        protected _body: Box2D.Dynamics.b2Body
        protected _targetPos: b2Vec2
        protected _type: PhyObjectType
        public get type(): PhyObjectType { return this._type }
        public get body(): Box2D.Dynamics.b2Body { return this._body }
        public get isTap(): boolean { return this._type == PhyObjectType.TapA || this._type == PhyObjectType.TapB }
        public get isTapA(): boolean { return this._type == PhyObjectType.TapA }
        public get isTapB(): boolean { return this._type == PhyObjectType.TapB }
        public get targetPos(): b2Vec2 { return this._targetPos }
        public get Pos(): Pos { return this._body.GetPosition() }

        constructor(type: PhyObjectType, body: Box2D.Dynamics.b2Body) {
            this._type = type
            this._body = body
            body.SetUserData(this)
        }

        public set targetPos(pos: b2Vec2) {
            this._targetPos = pos
        }

        public beforeStep() { }
        public afterStep() { }
    }
}